# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=binwally
pkgver=4.0aabd8b
pkgrel=4
groups=('blackarch' 'blackarch-binary')
pkgdesc='Binary and Directory tree comparison tool using the Fuzzy Hashing concept (ssdeep).'
url='https://github.com/bmaia/binwally'
arch=('any')
license=('MIT')
depends=('python2' 'cython2' 'python2-pydeep' 'ssdeep')
makedepends=('git')
source=("git+https://github.com/bmaia/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare(){
  cd $pkgname

  grep -iRl 'python' "$srcdir/binwally" |
  xargs sed -i 's|#!.*/usr/bin/python|#!/usr/bin/python2|;s|#!.*/usr/bin/env python$|#!/usr/bin/env python2|'

  grep -iRl 'ssdeep' "$srcdir/binwally" |
    xargs sed -i 's|ssdeep|pydeep|'
}

package() {
  cd $pkgname

  install -Dm 755 "$pkgname.py" "$pkgdir/usr/bin/$pkgname"
}

